﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Input;

using NSApplication;

using System.Windows;



using NSWPF;




namespace NSPresentation
{
   public static  class NSCoreCommandsBinder
    {
        static RoutedCommand editPsLayer = new RoutedCommand();

        public static RoutedCommand EditPsLayer
        {
            get { return NSCoreCommandsBinder.editPsLayer; }

        }


        static RoutedCommand runNS = new RoutedCommand();

        public static RoutedCommand RunNS
        {
            get { return NSCoreCommandsBinder.runNS; }
            
        }







        /// <summary>
        /// 将命令绑定到窗体
        /// </summary>
        /// <param name="window"></param>
        public static void BindCommandsToWindow(Window window)
        {
            CommandBinding cbRunNs = new CommandBinding();
            cbRunNs.Command = NSCoreCommandsBinder.RunNS;

            cbRunNs.CanExecute += new CanExecuteRoutedEventHandler(cbRunNs_CanExecute);
            cbRunNs.Executed += new ExecutedRoutedEventHandler(cbRunNs_Executed);

            window.CommandBindings.Add(cbRunNs);




            CommandBinding cbEditPs = new CommandBinding();
            cbEditPs.Command = NSCoreCommandsBinder.editPsLayer;
            cbEditPs.CanExecute += new CanExecuteRoutedEventHandler(cbEditPs_CanExecute);
            cbEditPs.Executed += new ExecutedRoutedEventHandler(cbEditPs_Executed);

            window.CommandBindings.Add(cbEditPs);







        }

        static void cbRunNs_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            //这里的计算由于采用的是c#版本，所以无法采用dos版计算的界面，该如何是好呢

            //先写一个作为测试用


            winRun run = new winRun();

            if (run.ShowDialog() == true)
            {


            }



        }

        static void cbRunNs_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (!ProjectService.CurrentService.BNullProj)
            {
                e.CanExecute = true;
                e.Handled = true;

            }

        }

        static void cbEditPs_Executed(object sender, ExecutedRoutedEventArgs e)
        {


            winPsList win = new winPsList(ProjectService.CurrentService.Project.NSData.PtLayer);

            if (win.ShowDialog() == true)
            {

                //GisService.CurrentService.CurrentMap.GeoMapFrame.SuspendEvents();

                //ProjectService.CurrentService.Project.NSData.PtLayer.ResetShapes(win.Shapes);

                //GisService.CurrentService.CurrentMap.GeoMapFrame.ResumeEvents();




            }



        }

        static void cbEditPs_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (!ProjectService.CurrentService.BNullProj)
            {
                e.CanExecute = true;
                e.Handled = true;

            }

        }




    }
}
